<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>3d-平移</title>
  <style>
    .box {
      width: 500px;
      height: 500px;
      border: 5px solid black;
      transform-style: preserve-3d;

      /*flat: 2d舞台 */
      /*preserve-3d: 3d舞台 */
      position: relative;
      margin: 0 auto;

      /* transform: rotateY(30deg); */

      perspective: 900px;
      /* 设置景深 可以用来判别3d的工具 */
    }

    .center {
      position: absolute;
      width: 200px;
      height: 200px;
      background: red;
      left: 50%;
      top: 50%;
      margin-left: -100px;
      margin-top: -100px;

      /* transform: translateZ(100px); */
      transition: all 2s;
    }

    .box:hover .center {
      /* transform: translateZ(100px); */
      transform: translate3d(0, 0px, 100px);
    }
  </style>
</head>

<body>
  <div class="box">
    <div class="center"></div>
  </div>
</body>

</html>